const fs = require('fs');
const path = require('path');

const getAllPathsSync = (directory) => {
  const filesAndDirs = fs.readdirSync(directory, { withFileTypes: true });
  let allPaths = [];

  for (const dirent of filesAndDirs) {
    const fullPath = path.join(directory, dirent.name);
    if (dirent.isDirectory()) {
      // 如果是目录，则递归调用
      allPaths = allPaths.concat(getAllPathsSync(fullPath));
    } else {
      // 是文件，直接添加到列表
      allPaths.push(fullPath);
    }
  }

  return allPaths;
};

// 使用示例
const directoryPath = './www/node'; // 替换为你的目录路径
const paths = getAllPathsSync(directoryPath);
fs.writeFileSync('generate_paths.json', JSON.stringify(paths, null, 4))
//console.log(paths);